package cn.wolfcode.trip.app.controller;


import cn.wolfcode.trip.base.domain.Credit;
import cn.wolfcode.trip.base.service.ICreditService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("credits")
public class CreditController {
    @Autowired
    private ICreditService creditService;

    /**
     * 获取当前用户积分对象
     * @param userId
     * @return
     */
    @GetMapping("{userId}")
    public Credit getCredits(@PathVariable("userId") Long userId){
        return creditService.getCredits(userId);
    }

    /**
     * 购买商品后更新用户积分 ckw
     * @return
     */
    @PostMapping("update")
    public JSONResult updateCredits(Long userId,int totalCredits){
        creditService.update(userId,totalCredits);
        return new JSONResult();
    }



}
